Skip to content

fix: merge runner config into workflow-triggered jobs#1098

Merged
dacbd merged 2 commits intomainfrom
fix/workflow-job-merge-runner-config
May 1, 2026
Merged

fix: merge runner config into workflow-triggered jobs#1098
dacbd merged 2 commits intomainfrom
fix/workflow-job-merge-runner-config

Conversation

@zacharyblasczyk
Copy link
Copy Markdown
Member

@zacharyblasczyk zacharyblasczyk commented May 1, 2026

Why

Workflow runs were dropping the JobAgent runner's serverUrl/apiKey when building the job, so the argo-workflow dispatcher had nothing to authenticate with. The deployment path already merges runner + deployment + version configs in jobeligibility/reconcile.go — workflows took a shortcut that skipped that step.

Changes

  • Fetch the runner row in dispatchJobForAgent and merge its config with the per-job WorkflowJobAgent.Config (per-job wins on conflict).
  • Tests cover credential preservation, override precedence, and nil inputs.

Summary by CodeRabbit

  • Improvements

    • Enhanced configuration handling for workflow-triggered jobs with improved merge logic.
  • Tests

    • Added test coverage for configuration merge scenarios, including credential preservation and value override handling.

Workflow runs were dropping serverUrl/apiKey from the JobAgent runner row,
so argo-workflow dispatch failed even though the same credentials work for
the deployment path (which already merges in jobeligibility).
Copilot AI review requested due to automatic review settings May 1, 2026 21:19
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

Warning

Rate limit exceeded

@zacharyblasczyk has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 39 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 299c8d74-9075-4329-9bcb-d41cac8274b5

📥 Commits

Reviewing files that changed from the base of the PR and between d2a73b7 and 159395c.

📒 Files selected for processing (2)
  • apps/workspace-engine/svc/http/server/openapi/workflows/setters.go
  • apps/workspace-engine/svc/http/server/openapi/workflows/workflows_test.go
📝 Walkthrough

Walkthrough

The changes introduce configuration merging when dispatching workflow-triggered jobs. The dispatchJobForAgent function now retrieves the persisted runner configuration, deep-merges it with the per-invocation workflow job payload, and marshals the result. Three new unit tests validate credential preservation, override behavior, and nil input handling.

Changes

Cohort / File(s) Summary
Workflow Job Configuration Merge
apps/workspace-engine/svc/http/server/openapi/workflows/setters.go, apps/workspace-engine/svc/http/server/openapi/workflows/workflows_test.go
Implements config merge logic in dispatchJobForAgent that combines persisted runner configuration with per-invocation job payload using deep merge semantics. Adds three unit tests validating credential preservation, per-job override behavior, and nil input handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A config dance, so graceful and neat,
Runner and payload in merger's beat,
Deep merge magic makes conflicts disperse,
Tests verify the logic averse,
Workflow jobs hop to success supreme!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: merging runner config into workflow-triggered jobs, which is the core fix addressing the authentication issue in the workflow dispatcher.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/workflow-job-merge-runner-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 21 minutes and 39 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes workflow-triggered job dispatch so the persisted job_agent_config includes the selected runner’s shared credentials (e.g., Argo Workflows serverUrl/apiKey) by merging the runner row config with per-job workflow agent config.

Changes:

  • Add mergeWorkflowJobAgentConfig helper to deep-merge runner config + per-job workflow config (per-job wins).
  • Update workflow job dispatch path to fetch the runner (job_agent) row and marshal the merged config into the job record.
  • Add unit tests covering credential preservation, override precedence, and nil inputs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
apps/workspace-engine/svc/http/server/openapi/workflows/setters.go Fetch runner row during workflow job dispatch and merge runner config with per-job workflow config before persisting job.
apps/workspace-engine/svc/http/server/openapi/workflows/workflows_test.go Adds unit tests for the merge behavior used by workflow-triggered job dispatch.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

func mergeWorkflowJobAgentConfig(
runnerConfig, perJobConfig map[string]any,
) oapi.JobAgentConfig {
return oapi.DeepMergeConfigs(runnerConfig, perJobConfig)
Comment on lines +122 to +127
runner, err := queries.GetJobAgentByID(ctx, jobAgentIDUUID)
if err != nil {
return fmt.Errorf("get job agent runner: %w", err)
}
mergedConfig := mergeWorkflowJobAgentConfig(runner.Config, jobAgent.Config)
jobAgentConfig, err := json.Marshal(mergedConfig)
jobAgentConfig, err := json.Marshal(jobAgent.Config)
runner, err := queries.GetJobAgentByID(ctx, jobAgentIDUUID)
if err != nil {
return fmt.Errorf("get job agent runner: %w", err)
Reject dispatch when the runner row's workspace doesn't match the
workflow's — without it, a workflow could reference a JobAgent UUID
from another workspace and pull its credentials into a job. Also
tightens the merge helper to take oapi.JobAgentConfig directly.
@zacharyblasczyk
Copy link
Copy Markdown
Member Author

Pushed 159395c addressing the Copilot review:

  • Cross-workspace credential disclosuredispatchJobForAgent now rejects when the fetched runner's workspace_id doesn't match the dispatching workspace, so a workflow can't pull a JobAgent UUID from another workspace.
  • Type tighteningmergeWorkflowJobAgentConfig takes oapi.JobAgentConfig directly. (The previous map[string]any form built fine — unnamed maps are assignable to the named type — but the named param is clearer.)
  • Error wordingget job agent runnerget job agent to match the table name.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

jobAgentIDUUID, workspaceIDUUID,
)
}
mergedConfig := mergeWorkflowJobAgentConfig(runner.Config, jobAgent.Config)
Comment on lines +122 to +125
workspaceIDUUID, err := uuid.Parse(workspaceID)
if err != nil {
return fmt.Errorf("parse workspace id: %w", err)
}
@dacbd dacbd merged commit 40c184e into main May 1, 2026
18 checks passed
@dacbd dacbd deleted the fix/workflow-job-merge-runner-config branch May 1, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants